#!/usr/bin/python
# -*- coding: utf-8 -*-
#Author: Onur ASLAN
#Mail : hata.pindir@gmail.com 

from PyQt4 import QtCore
from PyQt4 import QtGui

from Ui_MainWindow import Ui_MainWindow
import getpass
#import urllib2
import urllib


def control(self):
	self.frame_3.show() 	
	self.animate = QtCore.QPropertyAnimation (self.frame_3, "geometry")
	self.animate.setDuration (400)
	self.animate.setStartValue(QtCore.QRect (0, 400, 775, 382))
	self.animate.setEndValue(QtCore.QRect (0, -1, 771, 391))
	self.animate.start()
        site = urllib.urlopen("http://pindir.googlecode.com/svn/wiki/Version.wiki")
        version = site.read()
        surum = self.version.text()
 	dosyaa = open("/home/"+str(getpass.getuser())+"/.pindir_ayar.txt")
 	for satir in dosyaa:
  		a = satir
	dosyaa.readline()
        kullanilan_surum = surum[8:11]
       # print kullanilan_surum
        if version < kullanilan_surum:
		if a =="Türkçe": 
               		self.textBrowser.setText(unicode("Yeni Sürüm Yok"))
		if a == "English":
			self.textBrowser.setText(unicode("No New Version"))
               
               	self.indir_kur.setEnabled(False)
        if version >= kullanilan_surum:
		if a =="Türkçe": 
               		self.textBrowser.setText(unicode("Güncel Sürüm Yüklü"))
		if a == "English":
			self.textBrowser.setText(unicode("Installed current version "))
               	self.indir_kur.setEnabled(False)
            	
        if version > kullanilan_surum:
               	notal = urllib.urlopen("http://pindir.googlecode.com/svn/wiki/Yenilikler.wiki")
               	notlar = str(unicode((notal.read())))    
               	notal2 = urllib.urlopen("http://pindir.googlecode.com/svn/wiki/NewsEnglish.wiki")
               	notlar2 = str(unicode((notal2.read())))
               	self.indir_kur.setEnabled(True)
               	if a =="Türkçe": 
               		self.textBrowser.setText(notlar)
		if a == "English":
			self.textBrowser.setText(notlar2)

